package Algorithm.LinkListTest;

public class ReverseLinkList {

    public static ListNode reverseList(ListNode head) {

        if(head == null)  return null;

        ListNode cur = head ,prev = null;

        while(cur != null){
            ListNode tmp = cur.next;
            cur.next = prev;
            prev = cur;
            cur = tmp;
        }
        return prev;
    }


    public static void main(String[] args) {
        int[] nums = {1,3,2,7,9,4};
        ListNode listNode = new ListNode(nums);
        System.out.println(listNode);
        System.out.println(reverseList(listNode));
    }
}
